#!/bin/bash
set -e
set -x
MYDIR="${0%/*}"
cd "$MYDIR/.."
source "recipes/common.sh"


# RECIPE START binutils

reset_mtime binutils binutils/configure.ac
mkdir -p build/binutils
cd build/binutils
../../binutils/configure \
	--target=$TARGET \
	${CONFIGURE_ARGS} \
	--program-prefix="${TARGET}-" \
	--disable-bootstrap \
	--disable-multiarch \
	--disable-multilib \
	--disable-werror \
	--disable-nls \
	--enable-ld=default \
	--enable-64-bit-bfd \
	--enable-relro \
	--enable-textrel-check=warning \
	--enable-deterministic-archives \
	${NIL}

cd ../..

make -j${JOBS} -C build/binutils
make -j${JOBS} -C build/binutils install tooldir=${prefix} DESTDIR="$stage"
wipe_la_files "$stage"
# XXX: for some reason ld, ld.bfd and some other tools are NOT installed
for b in addr2line c++filt elfedit gprof ld ld.bfd size strings; do
	cp -al "${stage}${prefix}/bin/${TARGET}-${b}" "${stage}${prefix}/bin/${b}"
done

# RECIPE END binutils
